let config = require('../config.js').default;


export default class StuClass {
    static pageInit(goHash, param) {
        console.log("子页面初始化了,参数:", param);
        $("title").html("教室里面");
        let schoolInfo = this.getInfo();
        console.log("schoolInfo:", schoolInfo);

        let allHref = [];
        allHref.push("<ul>");

        //循环班级
        for (let a = 0; a < schoolInfo.stuClass.length; a++) {
            let clsA = schoolInfo.stuClass[a];
            allHref.push(`<li>班级：${clsA.name}</li>`);


            let teacher = clsA.teachers;
            let teacherLi = [];
            teacherLi.push("<ul>");
            for (let b = 0; b < teacher.length; b++) {
                const c = teacher[b];
                teacherLi.push(`<li>教师:${c.teacherName},科目:${c.profession},工作年限:${c.workYear}</li>`);
            }
            teacherLi.push("</ul>");
            allHref.push(`<li style='margin-left:1rem;'><ul>${teacherLi.join('')}<ul></li>`);

            let stu = clsA.students;
            let stuLi = [];
            stuLi.push("<ul>");
            for (let b = 0; b < stu.length; b++) {
                const c = stu[b];
                stuLi.push(`<li>学生:${c.stuName},成绩:${c.lastScore}</li>`);
            }
            stuLi.push("<ul>");
            allHref.push(`<li style='margin-left:1rem;'><ul>${stuLi.join('')}<ul></li>`);
        }

        // allHref.push(`<li>下一个页面&nbsp;<a href='#StuClass'>班级</a></li>`);
        allHref.push("</ul>");
        $("#classInfo").html(allHref.join(''));
    }
    static getInfo() {
        let rc = {
            stuClass: config.school.stuClass
        };
        return rc;
    }
}